<template>
  <div class="fullMain" style="height:100%;background-color:#F6F6F6;">
    <img style="width:150px;height:150px;float:right;" src="@/../static/img/download/arrow.png"/> 
    <!-- <br>
    <img style="width:300px;height:300px;" src="@/../static/img/download/circle.png"/>    -->
    <div style="height:200px;"></div>
    <div style="font-size:15px;text-align:center;border:1px gray dashed;line-height: 35px;border-radius: 50%;margin: 50px;padding: 10px;" 
    @click="download()">
      1.点击右上角
      <span style="font-size: 30px;color: red;">...</span><br>
      2.<i class="fa fa-globe" style="font-size: 25px;"></i>&nbsp;在浏览器打开<br>
      3.点击此处进行下载
    </div>

  </div>
</template>
<script>
  import downloadMenthod from 'utilMethods/download'
  import Vue from 'vue'
  Vue.component('a-test', {
    props: ['postTitle'],
    template: '<h3>{{ postTitle }}</h3>'
  }),
  new Vue({
    el: '#app',
  })

export default {

  name: 'Create',
  data(){
    return{
      url: '',
      token: '',
      fileName: ''
    }
  },
  mounted(){
    this.init()
  },
  methods:{
    init(){
      var test = window.location.search
      // 这种正则表达式，不兼容，火狐识别不了
      // var regToken = /(?<=token=).*?(?=&)/gm
      var start = test.indexOf('token=') + 6
      var end = test.indexOf('&url')
      this.token = test.substring(start,end)
      this.token = unescape(this.token)

      start = end + 5
      end = test.indexOf('&fileName')
      var tempUrl= test.substring(start,end)
      this.url = unescape(tempUrl)

      start = end + 10
      var tempFileName= test.substring(start)
      this.fileName = decodeURI(tempFileName)
      
      console.log("this.token::" + this.token)
      console.log("this.url::" + this.url)
      console.log("this.fileName::" + this.fileName)
    },
    download(){
      downloadMenthod.exportByXML(this.url,this.token,this.fileName,'Android')
    }
  }
}
</script>